<template lang="">
  <div>
    <!-- 操作按钮区域 -->
    <div class="btn-panel">
      <el-button type="success" size="small" icon="el-icon-plus" @click="detail"
        >查看详情</el-button
      >
      <el-button size="small" type="primary"   @click="pass"> <i class="fa fa-check-square-o"></i> 有意向</el-button>
      <el-button size="small" type="danger"   @click="unsuitable"><i class="	fa fa-ban"></i> 不合适</el-button>
    </div>
    <!-- 表格 -->
    <Table1
      ref="multipleTable"
      :tableData="tableData"
      :tableCols="tableCols"
      @showEditView="showEditView()"
      @deleteUser="del"
    >
  <template slot="slot_post" slot-scope="scope">
    {{scope.data.post.name}}
  </template>
  <template slot="slot_company" slot-scope="scope">
    {{scope.data.company.name}}
</template>
<template slot="slot_student" slot-scope="scope">
    {{scope.data.student.name}}
</template>
<template slot="slot_resume" slot-scope="scope">
    {{scope.data.resume.name}}
</template>
<template slot="slot_status" slot-scope="scope">
    <!--0待查看|1已查看|2有意向|3不合适-->
    <el-tag v-if="scope.data.status == 0">待查看</el-tag>
    <el-tag type="success" v-if="scope.data.status == 1">已查看</el-tag>
    <el-tag type="warning" v-if="scope.data.status == 2">有意向</el-tag>
    <el-tag type="danger" v-if="scope.data.status == 3">不合适</el-tag>
</template>
  </Table1>
    <div style="margin-top: 20px">
      <!-- 分页组件 -->
      <Page1
        :pages="pages"
        :total="total"
        @handleCurrentChange="handleCurrentChange"
        @handleSizeChange="handleSizeChange"
      ></Page1>
    </div>
  </div>
</template>
<script>
import Table1 from "@/components/Table1";
import Page1 from "@/components/Page1";

export default {
  name: "Send",
  components: { Table1, Page1 },
  data() {
    return {
      // 表格
      total: 0,
      pages: 1,
      currentPage: 1,
      size: 10,
      tableData: [],
      tableCols: [
        // {prop:'id', label:'ID', width:80},
        { prop: "post_id", label: "职位", slot: "slot_post" },
        { prop: "company_id", label: "公司", slot: "slot_company" },
        { prop: "student_id", label: "学生姓名", slot: "slot_student" },
        { prop: "resume_id", label: "简历名称", slot: "slot_resume" },
        { prop: "status", label: "状态", slot: "slot_status" },
        { prop: "send_date", label: "投递日期" },
      ],
      form: {
        postId: "",
      },
    };
  },
  mounted() {
    this.list();
  },
  methods: {
    list(form) {
      let url =
        "/send/queryPageCompany?currentPage=" +
        this.currentPage +
        "&size=" +
        this.size;
      this.postRequest(url, {form}).then((res) => {
        console.log(res, "分页查询的数据");
        this.tableData = res.data;
        this.total = res.total;
        this.pages = res.pages;
      });
    },
    // 当前页改变
    handleCurrentChange(page) {
      this.currentPage = page;
      this.list();
    },
    // 当前size改变
    handleSizeChange(size) {
      this.size = size;
      this.list();
    },
    // 查询
    search() {
      // this.postRequest("/post/queryByCon", this.searchForm).then((res) => {
      //   if (res) {
      //     console.log(res, "搜索后的数据");
      //     this.tableData = res;
      //   }
      // });
      this.list(this.form)
    },
    //详情
    detail(){
      let selection = this.$refs['mutipleTable'].selection;
            if(selection.length==1){
              if(selection[0].status == 0){
                let param = {"company_id":selection[0].company_id,"post_id":selection[0].post_id,"resume_id":selection[0].resume_id};
                param.status = 1;
                // this.getRequest("/send/detail",)
                // updateStatus(param).then(res=>{
                //   this.list(this.form);
                // }).catch(error=>{})
              }
              this.selectedId = selection[0].resumeId
              this.drawer= true;
            }else{
              this.$message.warning('请选择一条数据查看')
            }
    },

    // 点击编辑按钮事件
    showEditView() {
      // console.log(this.$refs["multipleTable"].data, "编辑事件");
      // let data = this.$refs["multipleTable"].data;
      // console.log("编辑修改", data);
      // this.edit.editForm = data;
      // console.log(this.edit.editForm);
      // this.edit.visible = true;
    },
    // 删除
    del() {
      console.log(this.$refs["multipleTable"].data, "删除事件");
      let data = this.$refs["multipleTable"].data;
      console.log("删除", data);
      this.$confirm(
        "此操作将永久删除职位：[" + data.name + "], 是否继续?",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          this.deleteRequest("/post/" + data.id).then((res) => {
            if (res) {
              console.log(res, "删除=======");
              this.$message.success(res.message);
              this.list();
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    // 批量删除
    deleteMany() {
      this.selection = this.$refs["multipleTable"].selection;
      console.log(this.selection, "批量删除");
      if (this.selection.length == 0) {
        this.$message.warning("请选择后再删除");
        return;
      }
      this.$confirm(
        "此操作将永久删除 [" + this.selection.length + "]个职位, 是否继续?",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          let ids = "?";
          this.selection.forEach((item) => {
            ids += "ids=" + item.id + "&";
          });
          console.log(ids, "ids===");
          this.deleteRequest("/post/" + ids).then((res) => {
            if (res.code == 200) {
              this.$message.success(res.message);
              this.list();
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    
  },
};
</script>
<style lang=""></style>
